package com.example.systemwork.service;

import com.example.systemwork.common.service.LogicService;
import com.example.systemwork.common.utils.Result;
import com.example.systemwork.dao.UserDao;
import com.example.systemwork.entity.Customer;
import com.example.systemwork.entity.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;



@Service
public class UserService extends LogicService<UserDao,User,Long> {

    public UserService(@Autowired UserDao dao) {
        super(dao);
    }

    public Result login(String username,String password){
        password= User.getMD5password(password);
        System.out.println(password);
        User user=getDAO().findByUsernameAndPassword(username,password);
        Result result=new Result();
        result.setId((long) -1);
        result.setUsername("*******用户名或密码错误*******");
        result.setType(-1);
        if(user!=null){
            result.setId(user.getId());
            result.setUsername(user.getUsername());
            result.setType(user.getType());
        }
        return result;
    }
}
